function HandleDialogLocation(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  this._name = (options && options.name) ? options.name : null;
  this._title = (options && options.title) ? options.title : null;
  
  this._createElements();
};

HandleDialogLocation.prototype._createElements = function() {
  this._loadData();
};

HandleDialogLocation.prototype._loadData = function() {
  DlmanageUtils.clear(this._gui);
  var img = DOMUtils.getLoadingImage();
  this._gui.content.appendChild(img);
  
  this._objects = null;
  this._retrieveObjects();
};

HandleDialogLocation.prototype._verifyData = function() {
  if (this._objects) {
    this._updateElements();
  }
};

HandleDialogLocation.prototype._retrieveObjects = function() {
  var _self = this;
  new RequestUtils()._read(this._name, null, null, null, null, null, null, function(result, params) { _self._objects = result.data;
                                                                                                      _self._verifyData.call(_self);
                                                                                                    }, null);
};

HandleDialogLocation.prototype._updateElements = function() {
  var select, img, table, tr, td, _self = this;
  DlmanageUtils.clear(this._gui);
  
  table = document.createElement('table');
  this._gui.content.appendChild(table);
  
  if (this._name == 'pz_payee') {
    tr = table.insertRow(-1);
    td = tr.insertCell(-1);
    td.style.padding = '0 5px 0 0 ';
    td.appendChild(document.createTextNode(this._title));
    td = tr.insertCell(-1);
    select = document.createElement('select');
    td.appendChild(select);
    select.options[select.options.length] = new Option('');
    select.style.width = '250px';
    for (var i = 0, il = this._objects.length; i < il; i++) {
      var object = this._objects[i];
      var option = new Option(object.name);
      select.options[select.options.length] = option;
      if (option.text == this._item.payee){
        select.selectedIndex = select.options.length - 1;
      }
    }
    select.onchange = function() { _self._item.payee = this.options[this.selectedIndex].text; };
  } 
  if (this._name == 'pz_particular') {
    tr = table.insertRow(-1);
    td = tr.insertCell(-1);
    td.style.padding = '0 5px 0 0 ';
    td.appendChild(document.createTextNode(this._title));
    td = tr.insertCell(-1);
    select = document.createElement('select');
    td.appendChild(select);
    select.options[select.options.length] = new Option('');
    select.style.width = '250px';
    for (var i = 0, il = this._objects.length; i < il; i++) {
      var object = this._objects[i];
      var option = new Option(object.name);
      select.options[select.options.length] = option;
      if (option.text == this._item.particular){
        select.selectedIndex = select.options.length - 1;
      }
    }
    select.onchange = function() { _self._item.particular = this.options[this.selectedIndex].text; };
  } 
  if (this._name == 'pz_category') {
    tr = table.insertRow(-1);
    td = tr.insertCell(-1);
    td.style.padding = '0 5px 0 0 ';
    td.appendChild(document.createTextNode(this._title));
    td = tr.insertCell(-1);
    select = document.createElement('select');
    td.appendChild(select);
    select.options[select.options.length] = new Option('');
    select.style.width = '250px';
    for (var i = 0, il = this._objects.length; i < il; i++) {
      var object = this._objects[i];
      var option = new Option(object.name);
      select.options[select.options.length] = option;
      if (option.text == this._item.category){
        select.selectedIndex = select.options.length - 1;
      }
    }
    select.onchange = function() { _self._item.category = this.options[this.selectedIndex].text; };
  } 
};

